package com.fantastic.controller;

import com.fantastic.anno.RedisDynamicLock;
import com.fantastic.anno.VerifyProperties;
import com.fantastic.dtos.req.RedissonReq;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : fantastic
 * @date : 2024/5/11 18:31
 * @desc : this class for xxxxx
 **/
@RestController
@RequestMapping("/learn/redisson/lock")
public class RedisLockController {

    @RedisDynamicLock(lockName = "testLock",key = "#req.orderId+':'+#req.userId" ,verifyProperties = {
            @VerifyProperties(express = "#req.orderId",name = "orderId"),
            @VerifyProperties(express = "#req.userId",name = "userId"),
    })
    @PostMapping("/redissonTest")
    public Integer redissonTest(@RequestBody RedissonReq req){
        try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return 200;
    }

}
